
#include "CSound.h"

CSound::CSound( Phonon::MediaSource &source )
{
    mediaObject = new Phonon::MediaObject( this );
    audioOutput = new Phonon::AudioOutput( this );
    Phonon::createPath( mediaObject, audioOutput );

    connect( mediaObject, SIGNAL(finished()), this, SLOT(finished()) );
    finish = true;

    mediaObject->setCurrentSource( source );
}

CSound::~CSound() {
    delete mediaObject;
    delete audioOutput;
}

void CSound::play( double sound ) {
    audioOutput->setVolume( sound );
    mediaObject->seek( 0 );
    mediaObject->play();
    finish = false;
}

bool CSound::isFinished() {
    return finish;
}

void CSound::finished() {
    mediaObject->pause();
    finish = true;
}
